using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace CoreManager.Models.Entities
{
    /// <summary>
    /// 刷新令牌实体
    /// </summary>
    public class RefreshToken : BaseEntity
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        [Column("user_id")]
        public int UserId { get; set; }

        /// <summary>
        /// 刷新令牌值
        /// </summary>
        [Required]
        [MaxLength(200)]
        [Column("token")]
        public string Token { get; set; } = string.Empty;

        /// <summary>
        /// 过期时间
        /// </summary>
        [Column("expires_at", TypeName = "datetime")]
        public DateTime ExpiresAt { get; set; }

        /// <summary>
        /// 是否已使用
        /// </summary>
        [Column("is_used")]
        public bool IsUsed { get; set; } = false;

        /// <summary>
        /// 是否已撤销
        /// </summary>
        [Column("is_revoked")]
        public bool IsRevoked { get; set; } = false;

        /// <summary>
        /// 客户端IP
        /// </summary>
        [MaxLength(50)]
        [Column("client_ip")]
        public string? ClientIp { get; set; }

        /// <summary>
        /// 用户代理
        /// </summary>
        [MaxLength(500)]
        [Column("user_agent")]
        public string? UserAgent { get; set; }

        /// <summary>
        /// 导航属性：用户
        /// </summary>
        public virtual User? User { get; set; }
    }
}